<?php if (!defined('THINK_PATH')) exit(); /*a:2:{s:80:"/home/wwwroot/www.lxlhome.com/public/../application/admin/view/article/edit.html";i:1556523506;s:71:"/home/wwwroot/www.lxlhome.com/application/admin/view/common/header.html";i:1555692011;}*/ ?>
<!doctype html>
<html  class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>管理员增加-LXL</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="stylesheet" href="/static/admin/css/font.css">
    <link rel="stylesheet" href="/static/common/css/public.css">
    <link rel="stylesheet" href="/static/common/lib/layui/css/layui.css">
    <link rel="stylesheet" href="/static/admin/css/xadmin.css">
    <script type="text/javascript" src="/static/common/jq/jquery.min.js"></script>
    <script type="text/javascript"src="/static/common/lib/md5/md5.min.js"></script>
    <script src="/static/common/lib/layui/layui.js" charset="utf-8"></script>

    <script type="text/javascript" src="/static/admin/js/xadmin.js"></script>
    <script type="text/javascript" src="/static/admin/js/cookie.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="/static/common/lib/ie/html5.min.js"></script>
    <script src="/static/common/lib/ie/respond.min.js"></script>
    <![endif]-->
    <script>
        // 是否开启刷新记忆tab功能
        // var is_remember = false;
    </script>
</head>
<body>
<script type="text/javascript" charset="utf-8" src="/static/common/lib/Neditor/neditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="/static/common/lib/Neditor/neditor.all.min.js"></script>
<script type="text/javascript" charset="utf-8" src="/static/common/lib/Neditor/neditor.service.js"></script>

<style>
    .layui-form-switch {
        margin-top: 6px;
    }
</style>
<div class="x-body">
    <form class="layui-form">
        <div class="layui-tab">
            <ul class="layui-tab-title">
                <li class="layui-this">基础设置</li>
                <li>内容编辑</li>
            </ul>
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <div class="layui-col-xs12">
                        <blockquote class="layui-elem-quote title"><i class="seraph icon-caidan"></i> 基本设置</blockquote>
                        <div class="border">
                            <div class="layui-row layui-col-space10">
                                <div class="layui-col-md9 layui-col-xs7">
                                    <div class="layui-form-item magt3">
                                        <label class="layui-form-label">标题</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="title" class="layui-input newsName"
                                                   lay-verify="title" value="<?php echo $data['title']; ?>"
                                                   placeholder="请输入标题" required>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">摘要</label>
                                        <div class="layui-input-block">
                                <textarea placeholder="请输入内容摘要" name="digest"
                                          class="layui-textarea abstract"><?php echo $data['digest']; ?></textarea>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-col-md3 layui-col-xs5">
                                    <div class="layui-upload-list thumbBox mag0 magt3">
                                        <img src="<?php echo !empty($data['pic'])?$data['pic']:''; ?>" class="layui-upload-img thumbImg">
                                    </div>
                                    <input type="hidden" name="pic" value="<?php echo !empty($data['pic'])?$data['pic']:''; ?>">
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-xs12">
                        <blockquote class="layui-elem-quote title"><i class="seraph icon-caidan"></i> SEO</blockquote>
                        <div class="border">
                            <div class="layui-row layui-col-space10">
                                <div class="layui-col-md9 layui-col-xs7">
                                    <div class="layui-form-item magt3">
                                        <label class="layui-form-label"> 关键词</label>
                                        <div class="layui-input-block">
                                            <input type="text" value="<?php echo $data['keywords']; ?>" name="keywords" class="layui-input" lay-verify=""
                                                   placeholder="关键词;多个以英文逗号“,”分隔">
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label"> 描述</label>
                                        <div class="layui-input-block">
                                <textarea placeholder="请输入描述" name="description"
                                          class="layui-textarea abstract"><?php echo $data['description']; ?></textarea>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-row layui-col-space10">
                        <div class="layui-col-md6 layui-col-xs12">
                            <blockquote class="layui-elem-quote title"><i class="seraph icon-caidan"></i> 分 类
                            </blockquote>
                            <div class="border">
                                <div class="layui-form-item">
                                    <label class="layui-form-label"> 所　属</label>
                                    <div class="layui-input-block">
                                        <select name="column_id" lay-verify="column_id" required>
                                            <option value="">请选择栏目</option>
                                            <?php if(is_array($columnList) || $columnList instanceof \think\Collection || $columnList instanceof \think\Paginator): $i = 0; $__LIST__ = $columnList;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$item): $mod = ($i % 2 );++$i;if($item['pid'] == '0'): ?>
                                            <option <?php echo $data['column_id']==$item['id']?'selected':''; ?>  value="<?php echo $item['id']; ?>"><?php echo $item['name']; ?></option>
                                            <?php else: ?>
                                            <option <?php echo $data['column_id']==$item['id']?'selected':''; ?> value="<?php echo $item['id']; ?>"><?php echo str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
                                                $item['level']); ?>|---<?php echo $item['name']; ?>
                                            </option>
                                            <?php endif; endforeach; endif; else: echo "" ;endif; ?>
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-form-item magt10">
                                    <label class="layui-form-label"> 来　源</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="source" class="layui-input" lay-verify=""
                                               placeholder="请输入来源" value="<?php echo !empty($data['source'])?$data['source']:''; ?>">
                                    </div>
                                </div>
                                <div class="layui-form-item magt10">
                                    <label class="layui-form-label"> 发布者</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="author"
                                               value="<?php echo !empty($data['author'])?$data['author']:''; ?>"
                                               class="layui-input" lay-verify="" placeholder="请输入作者">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md6 layui-col-xs12">
                            <blockquote class="layui-elem-quote title"><i class="layui-icon">&#xe609;</i> 发 布
                            </blockquote>
                            <div class="border">
                                <div class="layui-form-item">
                                    <label class="layui-form-label"><i class="layui-icon">&#xe60e;</i> 状　态</label>
                                    <div class="layui-input-block newsStatus">
                                        <select name="status" lay-verify="required">
                                            <option <?php echo $data['status']==0?'selected':''; ?>  value="0">立即发布</option>
                                            <option <?php echo $data['status']==1?'selected':''; ?> value="1">等待审核</option>
                                            <option <?php echo $data['status']==2?'selected':''; ?> value="2">保存草稿</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-col-md6 layui-col-xs12">
                                    <label class="layui-form-label"><i class="layui-icon">&#xe609;</i> 发　布</label>
                                    <div class="layui-input-block">
                                        <input type="radio" name="create_time" title="立即发布" lay-skin="primary"
                                               lay-filter="release"
                                               checked/>
                                        <input type="radio"  name="create_time" title="定时发布" lay-skin="primary"
                                               lay-filter="release"/>
                                    </div>
                                </div>
                                <div class="layui-form-item layui-hide releaseDate">
                                    <label class="layui-form-label"></label>
                                    <div class="layui-input-block">
                                        <input type="text" value="<?php echo !empty($data['publish'])?$data['publish']:''; ?>" name="publish_time" class="layui-input" id="release"
                                               placeholder="请选择日期和时间" readonly/>
                                    </div>
                                </div>
                                <div class="layui-form-item openness">
                                    <label class="layui-form-label"><i class="seraph icon-look"></i> 公开度</label>
                                    <div class="layui-input-block">
                                        <input type="radio" <?php echo $data['isopen']==0?'checked':''; ?> name="isopen" value="0" title="开放浏览" lay-skin="primary"
                                               checked/>
                                        <input type="radio" <?php echo $data['isopen']==1?'checked':''; ?>  name="isopen" value="1" title="私密浏览" lay-skin="primary"/>
                                    </div>
                                </div>
                                <div class="layui-form-item newsTop">
                                    <label class="layui-form-label"><i class="seraph icon-zhiding"></i> 置　顶</label>
                                    <div class="layui-input-block">
                                        <input type="checkbox" <?php echo $data['istop']==1?'checked':''; ?> name="istop" value="1" lay-skin="switch" lay-text="是|否">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-tab-item">
                    <div class="layui-col-xs12">
                        <!-- 加载编辑器的容器 -->
                        <script id="content" name="content" type="text/plain">
                            <?php echo $data['content']; ?>
                        </script>
                    </div>
                </div>
            </div>
        </div>
        <hr class="layui-bg-gray"/>
        <div class="layui-right">
            <a class="layui-btn layui-btn-sm" lay-filter="save" lay-submit><i
                    class="layui-icon">&#xe609;</i>发布</a>
            <a class="layui-btn layui-btn-primary layui-btn-sm" lay-filter="look"
               lay-submit>预览</a>
        </div>
        <input type="hidden" name="id" value="<?php echo $data['id']; ?>">
    </form>
</div>
<script>
    layui.use(['form', 'layer', 'laydate', 'upload'], function () {
        var form = layui.form,
            layer = parent.layer === undefined ? layui.layer : top.layer,
            upload = layui.upload,
            laydate = layui.laydate,
            $ = layui.jquery;

        var ue = UE.getEditor('content', {
            initialFrameWidth: '100%',
            initialFrameHeight: '550',
            autoHeight: false,
        });


        //定时发布
        var send_time = "<?php echo date('Y-m-d h:i:s',time()); ?>";
        laydate.render({
            elem: '#release',
            type: 'datetime',
            value: send_time,
            trigger: "click",
            done: function(value, date, endDate){
                send_time = value;
            }
        });
        form.on("radio(release)", function (data) {
            if (data.elem.title === "定时发布") {
                $(".releaseDate").removeClass("layui-hide");
                $(".releaseDate #release").attr("lay-verify", "required");
                $("#release").val(send_time);
            } else {
                $(".releaseDate").addClass("layui-hide");
                $("#release").removeAttr("lay-verify");
                $("#release").val('');
            }
        });
        //执行实例
        var uploadInst = upload.render({
            elem: '.thumbBox' //绑定元素
            , url: '<?php echo url("upload"); ?>' //上传接口
            , field: 'file'
            , accept: 'images'
            , drag: false
            , data: {
                old: function () {
                    return $('input[name="pic"]').val();
                }
            }
            , method: "post",
            done: function (res, index, upload) {
                $('.thumbImg').attr('src', res['url']);
                $('input[name="pic"]').val(res['url']);
                $('.thumbBox').css("background", "#fff");
            }
            , error: function () {
                layer.msg('缩略图上传失败!');
            }
        });

        //自定义验证规则
        form.verify({
            title: function (val) {
                if (val === '') {
                    return "文章标题不能为空";
                }
            },
            content: function (val) {
                if (val === "") {
                    return "内容不能为空";
                }
            },
            column_id: function (val) {
                if (val === "") {
                    return "必须选择所属栏目";
                }
            },
            time: function (val) {
                if (val === "") {
                    return "定时发布时间不能为空";
                }
            }
        });

        //预览
        form.on("submit(look)", function () {
            layer.alert("此功能需要前台展示，实际开发中传入对应的必要参数进行文章内容页面访问");
            return false;
        });

        //监听提交
        form.on('submit(save)', function (data) {

            //发异步，把数据提交给php
            $.post('<?php echo url("save"); ?>', {data: data.field}, function (reg) {
                switch (reg.code) {
                    case 0:
                        layer.msg(reg.msg, {icon: 6}, function () {
                            // 获得frame索引
                            var index = parent.layer.getFrameIndex(window.name);
                            //关闭当前frame
                            parent.layer.close(index);
                            // 可以对父窗口进行刷新
                            x_admin_father_reload();
                        });
                        break;
                    default:
                        layer.msg(reg.msg, {icon: 5});
                }

            }, 'json');
            return false;
        });


    });
</script>
</body>

</html>